Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 0 pax bug for multi-mission #625

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jkirk5
Copy link
Contributor

@jkirk5 jkirk5 commented Dec 9, 2024

Summary

Fixes a bug in the crew & payload preprocessor where providing a passenger count of 0 for a single mission was confused with not providing that particular passenger count variable at all, leading to overwriting mission pax count with design pax count.

Related Issues

  • Resolves #

Backwards incompatibilities

None

New Dependencies

None

@ehariton ehariton self-requested a review December 10, 2024 15:33
@ehariton ehariton assigned ehariton and unassigned ehariton Dec 10, 2024
Copy link
Contributor

@ehariton ehariton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_ben_FwFm.py fails on this PR.

File "/mnt/c/OMDAO/om-Aviary/aviary/validation_cases/benchmark_tests/test_bench_FwFm.py", line 397, in test_bench_FwFm_SNOPT
    compare_against_expected_values(prob, self.expected_dict)
  File "/mnt/c/OMDAO/om-Aviary/aviary/validation_cases/benchmark_utils.py", line 48, in compare_against_expected_values
    assert_near_equal(masses[-1], expected_masses[-1], tolerance=rtol)
  File "/mnt/c/OMDAO/openmdao/openmdao/utils/assert_utils.py", line 583, in assert_near_equal
    raise ValueError('actual %s, desired %s, %s error %s, tolerance %s'
ValueError: actual [43067.40134181], desired [62697.71513264], rel error 0.3130945641208417, tolerance 0.02

This code detects:
pax_provided True
design_pax_provided True

even though only Design information is provided in aircraft_for_bench_FwFm.csv

Examining aviary_options what we find is that 'aircraft:crew_and_payload:num_business_class': (0, 'unitless'), has been set before getting to the following code lines in preprocessor.py:

    for key in pax_keys:
        if key in aviary_options:
            # mark that the user provided any information on mission passenger count
            pax_provided = True
        else:
            # default all non-provided passenger info to 0
            aviary_options.set_val(key, 0)

@jkirk5
Copy link
Contributor Author

jkirk5 commented Dec 10, 2024

I will need to update docs once I have tests working

mission_pax = aviary_options.get_val(Aircraft.CrewPayload.NUM_PASSENGERS)
if mission_pax > design_pax:
if verbosity >= 1:
# TODO Should this be an error?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, i would just warn on this, just in case the user wants to run a mission overloaded with passengers (though where do they sit?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://www.guinnessworldrecords.com/world-records/most-passengers-on-an-aircraft
Over 1k people were crammed on a 747 once! So we'd be able to model that flight now

@jkirk5
Copy link
Contributor Author

jkirk5 commented Dec 27, 2024

Examining aviary_options what we find is that 'aircraft:crew_and_payload:num_business_class': (0, 'unitless'), has been set before getting to the following code lines in preprocessor.py:

It appears it is an issue stemming from the way load_vehicle() works, which is to grab every single variable from the metadata with a default and apply it to the aviary inputs. I think this is really bad because it has the potential to accidentally set default values as overrides which 100% isn't intended behavior. It also is really overkill, we only need to set values for inputs the user wants - every other default should come directly from the metadata when adding component inputs/outputs.

This PR may need to stay on hold until we clean up how defaults work in the rest of Aviary, this approach should work with the new paradigm (all defaults come from metadata rather than using user inputs as a vehicle to get those values into the problem)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants